package ctn.event.processor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import ctn.contant.UserConstant;
import ctn.event.CTNEventResetPWD;
import ctn.service.dto.CTNUserDTO;
import ctn.service.inteface.UserService;
import ctn.util.SecurityUtil;
@Component(value="resetPWDProcessor")
public class ResetPWDProcessor implements EventProcessor<CTNEventResetPWD> {
	@Autowired
	private UserService userService;
	@Override
	public void process(CTNEventResetPWD event) {
		CTNUserDTO cu=new CTNUserDTO();
		cu.setUserName(event.getUsrName());
		String pwd="";
		try {
			pwd = SecurityUtil.decode(event.getNewP(), UserConstant.USER_SECURITY_KEY_DEFAULT);
			cu.setPassword(pwd);
		} catch (Exception e) {
			e.printStackTrace();
		}
		userService.resetPass(cu);
		
	}

}
